import request from '@/utils/request'



export default{
  addResearch(data) {
    return request({
      url: `/research`,
      method: 'post',
      data: {
        FUN_TYPE:1,
        SUBJECT_PK_ID:data.subjectPkId,
        SUBJECT_NAME:data.researchName,
        SUBJECT_SIMPLE_NAME:data.researchSimpleName,
        SUBJECT_CODE:data.subjectCode,
        VP_INFO:data.vpInfo2,
        USER_ACCOUNT:data.piName,
        AGENCY_CODE:null,
        AGENCY_PK_ID:null,
        PI_PK_ID:null,
        CREATE_PK_ID:null,
        START_TIME:null,
        PLAN_FINISH_TIME:null,
        SUBJECT_STATUS:null,
        LOGO_URL:null,
        PLAN_CENTERNUM:1,
        PLAN_NUMBER:1,
        TYPE:data.type
      }
    })
  },

  updateResearch(data) {
    return request({
      url: `/research/updateAdmin`,
      method: 'put',
      data: {
        id:data.id,
        subjectPkId:data.subjectPkId,
        researchName:data.researchName,
        researchSimpleName:data.researchSimpleName,
        subjectCode:data.subjectCode,
        vpInfo:data.vpInfo2,
        piName:data.piName,
        type:data.type
      }
    })
  },

  getBysubjectPkId(subjectPkId) {
    return request({
      url: `/research/getBysubjectPkId?subjectPkId=${subjectPkId}`,
      method: 'get'
    })
  },

  researchSearch(piName,pageIndex,pageSize)
  {
    return request({
      url: `/research/search`,
      method: 'post',
      data: {
        piName:piName,
        pageNum:pageIndex,
        pageSize:pageSize
      }
    })
  },

  researchAllSearch(pageIndex,pageSize)
  {
    return request({
      url: `/research/searchAll`,
      method: 'post',
      data: {
        pageNum:pageIndex,
        pageSize:pageSize
      }
    })
  },

  researchAllAllSearch(pageIndex,pageSize)
  {
    return request({
      url: `/research/searchAllResearch`,
      method: 'post',
      data: {
        pageNum:pageIndex,
        pageSize:pageSize
      }
    })
  },

  deleteResearch(id)
  {
    return request({
      url: `/research/delete/${id}`,
      method: 'POST',
    })
  },

  getByResearchByUser(userName,pageNum,pageSize)
  {
    return request({
      url: `/research/getByResearchByUser?userName=${userName}&pageNum=${pageNum}&pageSize=${pageSize}`,
      method: 'get',
    })
  },

  updateSearchDoc(dataForm)
  {
    return request({
      url: `/research`,
      method: 'put',
      params:{
        id:dataForm.id,
        subjectPkId:dataForm.subjectPkId,
        experimentSpecification:dataForm.experimentSpecification,
      }
    })
  },

  updateSearchSampleRate(id,sampleRate,subjectPkId)
  {

    return request({
        url: `/research`,
        method: 'put',
        params: {
          id:id,
          subjectPkId: subjectPkId,
          sampleRate: sampleRate,
        }
      }
    )
  },

  getSiteStat(subjectPkId,sitePkId)
  {
    return request({
      url: `/research/getSiteStat?subjectPkId=${subjectPkId}&sitePkId=${sitePkId}`,
      method: 'get'
    })
  },

  getResearchStat(subjectPkId)
  {
    return request({
      url: `/research/getResearchStat?subjectPkId=${subjectPkId}`,
      method: 'get'
    })
  },

  getResearchStatByUser(userName)
  {
    return request({
      url: `/research/getResearchStatByUser?userName=${userName}`,
      method: 'get'
    })
  }

}
